<?php
/**
 * Created by PhpStorm.
 * User: mac1
 * Date: 16/6/10
 * Time: 上午10:32
 */

namespace app\admin\controller;
use app\admin\model\Admintype;
use app\admin\model\Campus;
use app\admin\validate\AdminValidate;
use think\Db;
use app\admin\model\Admin;

class ApishowController extends CommonController
{

//    public function jz(){
//        $da = Db::table('ew_hot')->select();
//        foreach ($da as $k=>$v){
//            $id = $v['h_id'];
//            $time = $v['h_time'];
//            Db::table('ew_hot')->where('h_id',$id)
//                ->update(['h_ordertime'=>$time]);
//        }
//    }

	//public function hot2222(){
	//	set_time_limit(0);
	//	$das = Db::table('ew_hot')->select();
	//	foreach($das as $da){
	//		$url = $da['h_url'];
	//		$a = str_replace('paz3uzuv1.bkt.clouddn.com', 'qiniu.mangmeshi.com',$url); // zesz
	//		$res = Db::table('ew_hot')->where('h_id',$da['h_id'])->update(['h_url'=>$a]);
	//	}
	//	
	//}
    /**
     * show数据
     * page
     * @return string
     */
    public function showData(){
        extract(input());
        $auth = $this->checkAll($user_id,$time,$value,$reqKey);
        if($auth == false){
            $returnData['status'] = 301;
            $returnData['msg'] = "Token失效！请重新登录！";
            return json_encode($returnData);
        }
        //=============================================
        $black = Db::table('ew_black')->where('b_user_id',$user_id)->column('b_black_uid');
        if(!$black){$black = array(0);}
        //=============================================
        $field = 'h_id,h_url,h_title,h_time,h_num,h_zan';
        $data = Db::table('ew_hot')
            ->where('h_user_id','not in',$black)
            ->field($field)
//            ->order('h_top DESC,h_time DESC')
            ->order('h_ordertime DESC')
            ->limit(($page-1)*10,10)
            ->select();
        $zandata = Db::table('ew_hot_zan')->where('cz_user_id',$user_id)->column('cz_hot_id');
        if($data){
            foreach ($data as $k=>$v){
                $data[$k]['zan'] = 0;//没有点赞
                if($zandata){
                    if(in_array($v['h_id'],$zandata)){
                        $data[$k]['zan'] = 1;//已经点赞
                    }
                }
            }
        }
        return json_encode(['status'=>200,'msg'=>$data]);
    }

    /**
     * h_id
     * @return \think\response\Json
     * show详情
     */
    public function getHotContentNew(){
        extract(input());
        $auth = $this->checkAll($user_id,$time,$value,$reqKey);
        if($auth == false){
            return json(['status'=>301,'msg'=>"Token失效！请重新登录！"]);
        }
        $data[1] = Db::table('ew_hot')->alias('h')
            ->join('ew_u_user u','h.h_user_id=u.user_id','LEFT')
            ->where('h.h_id',$h_id)
            ->field('h_id,h_url,h_title,h_time,h_num,h_zan,h_message,user_id,user_username,user_image,h_ordertime')
            ->find();
        $h_ordertime = $data[1]['h_ordertime'];
        $data[0] = array();
        $data[2] = array();
        $data_shang = Db::table('ew_hot')->alias('h')
            ->join('ew_u_user u','h.h_user_id=u.user_id','LEFT')
            ->where('h_id','<>',$h_id)
            ->where('h_ordertime','>=',$h_ordertime)
            ->order('h_ordertime ASC')
            ->field('h_id,h_url,h_title,h_time,h_num,h_zan,h_message,user_id,user_username,user_image,h_ordertime')
            ->find();
        $data_xia = Db::table('ew_hot')->alias('h')
            ->join('ew_u_user u','h.h_user_id=u.user_id','LEFT')
            ->where('h_id','<>',$h_id)
            ->where('h_ordertime','<=',$h_ordertime)
            ->order('h_ordertime DESC')
            ->field('h_id,h_url,h_title,h_time,h_num,h_zan,h_message,user_id,user_username,user_image,h_ordertime')
            ->find();
        Db::table('ew_hot')->where('h_id',$h_id)->setInc('h_num');
        if($data_shang){$data[0] = $data_shang;}
        if($data_xia){$data[2] = $data_xia;}
        foreach ($data as $k=>$v){
            $data[$k]['zan'] = 0;//没有点赞
            if($v){
                $havezan = Db::table('ew_hot_zan')
                    ->where('cz_user_id',$user_id)
                    ->where('cz_hot_id',$v['h_id'])
                    ->find();
                if($havezan){
                    $data[$k]['zan'] = 1;
                }
            }
        }
        $prev = $data[0];
        $now = $data[1];
        $next = $data[2];
        return json(['status'=>200,'prev'=>$prev,'now'=>$now,'next'=>$next]);
    }
    /**
     * h_id
     * @return \think\response\Json
     * show详情
     */
    public function getHotContent(){
        header("Access-Control-Allow-Origin:*");
        extract(input());
        if(!isset($share)){
            $auth = $this->checkAll($user_id,$time,$value,$reqKey);
            if($auth == false){
                return json(['status'=>301,'msg'=>"Token失效！请重新登录！"]);
            }
        }
        $data = Db::table('ew_hot')->alias('h')
            ->join('ew_u_user u','h.h_user_id=u.user_id','LEFT')
            ->where('h.h_id',$h_id)
            ->field('h_id,h_url,h_title,h_time,h_num,h_zan,h_message,user_id,user_username,user_image')
            ->find();
        if(!$data){
            return json_encode(['status'=>0,'msg'=>'此内容已被删除']);
        }
        Db::table('ew_hot')->where('h_id',$h_id)->setInc('h_num');
        $havezan = Db::table('ew_hot_zan')
            ->where('cz_user_id',$user_id)
            ->where('cz_hot_id',$h_id)
            ->find();
        $zan = 0;
        if($havezan){
            $zan = 1;
        }
        return json(['status'=>200,'msg'=>$data,'zan'=>$zan]);
    }
    /**
     * show的评论展示
     * h_id，page
     * @return string
     */
    public function hotComment(){
        header("Access-Control-Allow-Origin:*");
        extract(input());
//        $auth = $this->checkAll($user_id,$time,$value,$reqKey);
//        if($auth == false){
//            $returnData['status'] = 301;
//            $returnData['msg'] = "Token失效！请重新登录！";
//            return json_encode($returnData);
//        }
        //详情页有两条
        $pageNum = 10;
        if(isset($length) && $length){
            $pageNum = $length;
        }
        $data = Db::table('ew_hot')
            ->where('h_id',$h_id)
            ->field('h_id')
            ->find();
        if(!$data){
            return json_encode(['status'=>0,'msg'=>'此内容已被删除']);
        }
        $coms = Db::table('ew_hot_comment_tt')->alias('ct')
            ->join('ew_u_user u','ct.comtt_one_user_id=u.user_id','LEFT')
            ->join('ew_u_user u2','ct.comtt_reply_user_id=u2.user_id','LEFT')
            ->field('u.user_id one_id,u2.user_id reply_id,u.user_username one_name,u2.user_username reply_name,u.user_image one_image,u2.user_image reply_image,comtt_content,comtt_time,comtt_id,comtt_zan')
            ->where('comtt_comment_id',$h_id)
            ->limit(($page-1)*10,$pageNum)
            ->select();
        if($coms){
            foreach ($coms as $k=>$v){
                $coms[$k]['iszan'] = 0;
                $have = Db::table('ew_hot_comment_zan')
                    ->where('hh_hot_comment_id',$v['comtt_id'])
                    ->where('hh_user_id',$user_id)
                    ->find();
                if($have){
                    $coms[$k]['iszan'] = 1;
                }
            }
        }
        return json_encode(['status'=>200,'msg'=>$coms]);

    }
    /**
     * 直接评论
     * h_id,content
     * @return string
     */
    public function insertCmOne(){
        extract(input());
        $auth = $this->checkAll($user_id,$time,$value,$reqKey);
        if($auth == false){
            $returnData['status'] = 301;
            $returnData['msg'] = "Token失效！请重新登录！";
            return json_encode($returnData);
        }
        // 启动事务
        Db::startTrans();
        try{
            $data = array();
            $data['comtt_one_user_id'] = $user_id;
            $data['comtt_comment_id'] = $h_id;
            $data['comtt_content'] = $content;
            $data['comtt_time'] = date('Y-m-d H:i:s');
            Db::table('ew_hot_comment_tt')->insert($data);
            //========================
            Db::table('ew_hot')
                ->where('h_id',$h_id)
                ->setInc('h_message');
            //========================

            /*-----------------加入消息表------------------*/
            $notice = array();
            $notice['n_where'] = 5;
            $need = Db::table('ew_hot')->where('h_id',$h_id)->value('h_user_id');
            $time = date('Y-m-d H:i:s');
            $notice['n_time'] = $time;
            $notice['n_user_id'] = $need;//给谁留言
            $notice['n_reply_user_id'] = $user_id;//谁留言
            $notice['n_circle_id'] = $h_id;//哪个动态
            $notice['n_title'] = "在{$time}的时候给您回复了，回复内容：{$content}";
            Db::table('ew_notice')->insert($notice);
            /*----------------------end------------------*/
            // 提交事务
            Db::commit();
            /*-----------推送和透传------------*/
            $name = Db::table('ew_u_user')->where('user_id',$user_id)->value('user_username');
            $this->sendJpush("$need","{$name}回复了您的动态",array('aa'=>'bb'),1);
            /*-----------end------------*/
            return json_encode(['status'=>200,'msg'=>'成功']);
            //=====end===============
        } catch (\Exception $e) {
            Db::rollback();
            return json_encode(['status'=>0,'msg'=>'失败']);
        }
    }
    /**
     * 评论show的回复的回复
     * uid,h_id,content
     * @return string
     */
    public function insertCmTwo(){
        extract(input());
        $auth = $this->checkAll($user_id,$time,$value,$reqKey);
        if($auth == false){
            $returnData['status'] = 301;
            $returnData['msg'] = "Token失效！请重新登录！";
            return json_encode($returnData);
        }
        // 启动事务
        Db::startTrans();
        try{
            $data = array();
            $data['comtt_one_user_id'] = $uid;
            $data['comtt_reply_user_id'] = $user_id;
            $data['comtt_comment_id'] = $h_id;
            $data['comtt_content'] = $content;
            $data['comtt_time'] = date('Y-m-d H:i:s');
            Db::table('ew_hot_comment_tt')->insert($data);
            //========================
            Db::table('ew_hot')
                ->where('h_id',$h_id)
                ->setInc('h_message');
            //========================

            /*-----------------加入消息表------------------*/
            $notice = array();
            $notice['n_where'] = 5;
            //备用：如果也需要给发布人提醒的话就两条
            //$need = Db::table('ew_circle')->where('circle_id',$circle_id)->value('circle_user_id');
            $time = date('Y-m-d H:i:s');
            $notice['n_time'] = $time;
            $notice['n_user_id'] = $uid;//给谁留言
            $notice['n_reply_user_id'] = $user_id;//谁留言
            $notice['n_circle_id'] = $h_id;//哪个动态
            $notice['n_title'] = "在{$time}的时候给您回复了，回复内容：{$content}";
            Db::table('ew_notice')->insert($notice);
            /*----------------------end------------------*/

            // 提交事务
            Db::commit();
            /*-----------推送和透传------------*/
            $name = Db::table('ew_u_user')->where('user_id',$user_id)->value('user_username');
            $this->sendJpush("$uid","{$name}回复了您",array('aa'=>'bb'),1);
            /*-----------end------------*/
            return json_encode(['status'=>200,'msg'=>'成功']);
            //=====end===============
        } catch (\Exception $e) {
            Db::rollback();
            return json_encode(['status'=>0,'msg'=>'失败']);
        }
    }
    /**
     * 点赞或者取消点赞
     * h_id
     * @return string
     */
    public function zanStatus(){
        extract(input());
        $auth = $this->checkAll($user_id,$time,$value,$reqKey);
        if($auth == false){
            $returnData['status'] = 301;
            $returnData['msg'] = "Token失效！请重新登录！";
            return json_encode($returnData);
        }
        $who = Db::table('ew_hot')->where('h_id',$h_id)->value('h_user_id');
        // 启动事务
        Db::startTrans();
        try{
            $res = Db::table('ew_hot_zan')
                ->where('cz_hot_id',$h_id)
                ->where('cz_user_id',$user_id)
                ->find();
            if($res){
                Db::table('ew_hot_zan')
                    ->where('cz_hot_id',$h_id)
                    ->where('cz_user_id',$user_id)
                    ->delete();
                Db::table('ew_hot')
                    ->where('h_id',$h_id)
                    ->setDec('h_zan');
                Db::table('ew_u_user')->where('user_id',$who)->setDec('user_zan');
            }else{
                Db::table('ew_hot_zan')
                    ->insert(['cz_hot_id'=>$h_id,'cz_user_id'=>$user_id]);
                Db::table('ew_hot')
                    ->where('h_id',$h_id)
                    ->setInc('h_zan');
                Db::table('ew_u_user')->where('user_id',$who)->setInc('user_zan');
            }
            //========================
            // 提交事务
            Db::commit();
            return json_encode(['status'=>200,'msg'=>'成功']);
            //=====end===============
        } catch (\Exception $e) {
            Db::rollback();
            return json_encode(['status'=>0,'msg'=>'失败']);
        }
    }
    /**
     * 发布show
     *
     * @return string
     */
    public function createShow(){
        extract(input());
        $auth = $this->checkAll($user_id,$time,$value,$reqKey);
        if($auth == false){
            $returnData['status'] = 301;
            $returnData['msg'] = "Token失效！请重新登录！";
            return json_encode($returnData);
        }
        $data = array();
        $data['h_title'] = $title;
        $data['h_url'] = $url;
        $data['h_time'] = date('Y-m-d H:i:s');
        $data['h_user_id'] = $user_id;
        $data['h_ordertime'] = date('Y-m-d H:i:s');
        $res = Db::table('ew_hot')->insert($data);
        if($res){
            return json_encode(['status'=>200,'msg'=>'成功']);
        }else{
            return json_encode(['status'=>0,'msg'=>'失败']);
        }
    }

    /*------------------------排行榜----------------------------------------------*/
    /**
     * show榜单数据
     *
     * @return string
     */
    public function showTop(){
        header("Access-Control-Allow-Origin:*");
        extract(input());
        if($user_id !=0){
            $auth = $this->checkAll($user_id,$time,$value,$reqKey);
            if($auth == false){
                $returnData['status'] = 301;
                $returnData['msg'] = "Token失效！请重新登录！";
                return json_encode($returnData);
            }
        }

        $field = 'user_username,user_id,user_image,user_zan';
        $data = Db::table('ew_u_user')
            ->field($field)
            ->order('user_zan DESC')
            ->limit(0,6)
            ->select();
        $zannum = Db::table('ew_hot_top_zan')->count();
        $msgnum = Db::table('ew_hot_top_message')->count();
        $zan = 0;
        $havzan = Db::table('ew_hot_top_zan')
            ->where('cz_user_id',$user_id)
            ->find();
        if($havzan){
            $zan = 1;
        }
        $myzan = Db::table('ew_u_user')->where('user_id',$user_id)->value('user_zan');
//        if($data){
//            foreach ($data as $k=>$v){
//                if($k == 0){$data[$k]['top_name'] = '状元';}
//                if($k == 1){$data[$k]['top_name'] = '榜眼';}
//                if($k == 2){$data[$k]['top_name'] = '探花';}
//                if($k == 3){$data[$k]['top_name'] = '举人';}
//                if($k == 4){$data[$k]['top_name'] = '秀才';}
//                if($k == 5){$data[$k]['top_name'] = '童生';}
//            }
//        }
        return json_encode(['status'=>200,'msg'=>$data,'zannum'=>$zannum,'msgnum'=>$msgnum,'zan'=>$zan,'myzan'=>$myzan]);
    }
    /**
     * 榜单——评论数据
     * page
     * @return string
     */
    public function showTopMessage(){
        header("Access-Control-Allow-Origin:*");
        extract(input());
        if($user_id !=0){
            $auth = $this->checkAll($user_id,$time,$value,$reqKey);
            if($auth == false){
                $returnData['status'] = 301;
                $returnData['msg'] = "Token失效！请重新登录！";
                return json_encode($returnData);
            }
        }
        $field = 'u.user_id one_id,u2.user_id reply_id,u.user_username one_name,u2.user_username reply_name';
        $field .= ',cm_content,cm_time,u.user_image one_image,u2.user_image reply_image';
        $field .= ',cm_zan,top_id';
        $data = Db::table('ew_hot_top_message')->alias('m')
            ->join('ew_u_user u','m.cm_one_user_id=u.user_id','LEFT')
            ->join('ew_u_user u2','m.cm_reply_user_id=u2.user_id','LEFT')
            ->field($field)
            ->order('cm_time DESC')
            ->limit(($page-1)*10,10)
            ->select();
        if($data){
            foreach ($data as $k=>$v){
                $data[$k]['iszan'] = 0;
                $have = Db::table('ew_hot_top_message_zan')
                    ->where('hhtt_hot_top_message_id',$v['top_id'])
                    ->where('hhtt_user_id',$user_id)
                    ->find();
                if($have){
                    $data[$k]['iszan'] = 1;
                }
            }
        }
        return json_encode(['status'=>200,'msg'=>$data]);
    }
    /**
     * 直接评论
     * content
     * @return string
     */
    public function insertTopOne(){
        extract(input());
        $auth = $this->checkAll($user_id,$time,$value,$reqKey);
        if($auth == false){
            $returnData['status'] = 301;
            $returnData['msg'] = "Token失效！请重新登录！";
            return json_encode($returnData);
        }
        $data = array();
        $data['cm_one_user_id'] = $user_id;
        $data['cm_content'] = $content;
        $data['cm_time'] = date('Y-m-d H:i:s');
        $res = Db::table('ew_hot_top_message')->insert($data);
        if($res){
            return json_encode(['status'=>200,'msg'=>'成功']);
        }else{
            return json_encode(['status'=>0,'msg'=>'失败']);
        }
    }
    /**
     * 评论回复的回复
     * uid,content
     * @return string
     */
    public function insertTopTwo(){
        extract(input());
        $auth = $this->checkAll($user_id,$time,$value,$reqKey);
        if($auth == false){
            $returnData['status'] = 301;
            $returnData['msg'] = "Token失效！请重新登录！";
            return json_encode($returnData);
        }
        // 启动事务
        Db::startTrans();
        try{
            $data = array();
            $data['cm_one_user_id'] = $uid;
            $data['cm_reply_user_id'] = $user_id;
            $data['cm_content'] = $content;
            $data['cm_time'] = date('Y-m-d H:i:s');
            Db::table('ew_hot_top_message')->insert($data);
            /*-----------------加入消息表------------------*/
//            $notice = array();
//            $notice['n_where'] = 3;
//            //备用：如果也需要给发布人提醒的话就两条
//            //$need = Db::table('ew_circle')->where('circle_id',$circle_id)->value('circle_user_id');
//            $time = date('Y-m-d H:i:s');
//            $notice['n_time'] = $time;
//            $notice['n_user_id'] = $uid;//给谁留言
//            $notice['n_reply_user_id'] = $user_id;//谁留言
//            $notice['n_circle_id'] = $circle_id;//哪个动态
//            $notice['n_title'] = "在{$time}的时候给您回复了，回复内容：{$content}";
//            Db::table('ew_notice')->insert($notice);
            /*----------------------end------------------*/

            // 提交事务
            Db::commit();
            /*-----------推送和透传------------*/
            $name = Db::table('ew_u_user')->where('user_id',$user_id)->value('user_username');
            $this->sendJpush("$uid","{$name}回复了您",array('aa'=>'bb'),1);
            /*-----------end------------*/
            return json_encode(['status'=>200,'msg'=>'成功']);
            //=====end===============
        } catch (\Exception $e) {
            Db::rollback();
            return json_encode(['status'=>0,'msg'=>'失败']);
        }
    }
    /**
     * 点赞或者取消点赞
     * h_id
     * @return string
     */
    public function zanTopStatus(){
        extract(input());
        $auth = $this->checkAll($user_id,$time,$value,$reqKey);
        if($auth == false){
            $returnData['status'] = 301;
            $returnData['msg'] = "Token失效！请重新登录！";
            return json_encode($returnData);
        }
        // 启动事务
        Db::startTrans();
        try{
            $res = Db::table('ew_hot_top_zan')
                ->where('cz_user_id',$user_id)
                ->find();
            if($res){
                Db::table('ew_hot_top_zan')
                    ->where('cz_user_id',$user_id)
                    ->delete();
            }else{
                Db::table('ew_hot_top_zan')
                    ->insert(['cz_user_id'=>$user_id]);
            }
            //========================
            // 提交事务
            Db::commit();
            return json_encode(['status'=>200,'msg'=>'成功']);
            //=====end===============
        } catch (\Exception $e) {
            Db::rollback();
            return json_encode(['status'=>0,'msg'=>'失败']);
        }
    }


    /**
     * 打榜规则
     * h_id
     * @return string
     */
    public function getTopRole()
    {
        extract(input());
        $auth = $this->checkAll($user_id, $time, $value, $reqKey);
        if ($auth == false) {
            $returnData['status'] = 301;
            $returnData['msg'] = "Token失效！请重新登录！";
            return json_encode($returnData);
        }
        $data = Db::table('ew_personalconfig')->where('id',6)->value('remark');
        return json_encode(['status'=>200,'msg'=>$data]);
    }
    //************************同意点赞和取消点赞*****************************************************************
    /**
     * 统一的评论的点赞的接口
     * type和id和who(传给谁点赞的id)
     * @return string
     */
    public function commonZanOrNot()
    {
        extract(input());
        if ($user_id == 0) {
            $returnData['status'] = 0;
            $returnData['msg'] = "游客不能点赞，请登录！";
            return json_encode($returnData);
        }
        //type：1是圈  2是秀  3是榜单  4发布
        if($type == 1){
            $restable = 'ew_circle_message_zan';
            $mother = 'ew_circle_message';
            $resvaluefield1 = 'cc_circle_message_id';
            $resvaluefield2 = 'cc_user_id';
            $motheridfield = 'cm_id';
            $motherincdec = 'cm_zan';
        }elseif ($type == 2){
            $restable = 'ew_hot_comment_zan';
            $mother = 'ew_hot_comment_tt';
            $resvaluefield1 = 'hh_hot_comment_id';
            $resvaluefield2 = 'hh_user_id';
            $motheridfield = 'comtt_id';
            $motherincdec = 'comtt_zan';
        }elseif ($type == 3){
            $restable = 'ew_hot_top_message_zan';
            $mother = 'ew_hot_top_message';
            $resvaluefield1 = 'hhtt_hot_top_message_id';
            $resvaluefield2 = 'hhtt_user_id';
            $motheridfield = 'top_id';
            $motherincdec = 'cm_zan';
        }elseif ($type == 4){
            $restable = 'ew_life_message_zan';
            $mother = 'ew_life_message';
            $resvaluefield1 = 'll_life_message_zan';
            $resvaluefield2 = 'll_user_id';
            $motheridfield = 'lm_id';
            $motherincdec = 'lm_zan';
        }else{
            return json_encode(['status'=>0,'msg'=>'参数错误！']);
        }
        // 启动事务
        Db::startTrans();
        try{
            $res = Db::table("$restable")
                ->where("$resvaluefield1",$id)
                ->where("$resvaluefield2",$user_id)
                ->find();
            if($res){
                Db::table("$restable")
                    ->where("$resvaluefield1",$id)
                    ->where("$resvaluefield2",$user_id)
                    ->delete();
                Db::table("$mother")
                    ->where("$motheridfield",$id)
                    ->setDec("$motherincdec");
                Db::table('ew_u_user')->where('user_id',$who)->setDec('user_zan');
            }else{
                Db::table("$restable")
                    ->insert(["$resvaluefield1"=>$id,"$resvaluefield2"=>$user_id]);
                Db::table("$mother")
                    ->where("$motheridfield",$id)
                    ->setInc("$motherincdec");
                Db::table('ew_u_user')->where('user_id',$who)->setInc('user_zan');
            }
            //========================
            // 提交事务
            Db::commit();
            return json_encode(['status'=>200,'msg'=>'成功']);
            //=====end===============
        } catch (\Exception $e) {
            Db::rollback();
            return json_encode(['status'=>0,'msg'=>'失败']);
        }
    }

    /**
     * 统一删除我的评论的接口
     * type和id
     * @return string
     */
    public function deleteFourTypes()
    {
        extract(input());
        if ($user_id == 0) {
            $returnData['status'] = 0;
            $returnData['msg'] = "游客不能点赞，请登录！";
            return json_encode($returnData);
        }
        //type：1是圈  2是秀  3是榜单  4发布
        if($type == 1){
            $mother = 'ew_circle_message';
            $motheridfield = 'cm_id';
        }elseif ($type == 2){
            $mother = 'ew_hot_comment_tt';
            $motheridfield = 'comtt_id';
        }elseif ($type == 3){
            $mother = 'ew_hot_top_message';
            $motheridfield = 'top_id';
        }elseif ($type == 4){
            $mother = 'ew_life_message';
            $motheridfield = 'lm_id';
        }else{
            return json_encode(['status'=>0,'msg'=>'参数错误！']);
        }
        $res = Db::table("$mother")->where("$motheridfield",$id)->delete();
        if($res){
            return json_encode(['status'=>200,'msg'=>'成功']);
        }else{
            return json_encode(['status'=>0,'msg'=>'失败']);
        }
    }
}